package com.settlement.system.mapper;

import com.settlement.system.model.entity.common.SinglePage;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.session.ResultHandler;

import java.util.List;
import java.util.Map;

/**
 * @author author
 */
public interface BaseMapper {

    /**
     * 插入一条数据
     * @param modelType
     * @return Integer
     */
    public abstract <ModelType> Integer insert(ModelType modelType);

    /**
     * 更新数据
     * @param modelType
     * @return Integer
     */
    public abstract <ModelType> Integer update(ModelType modelType);

    /**
     * 删除数据
     * @param modelType
     * @return Integer
     */
    public abstract <ModelType> Integer deleteById(ModelType modelType);

    Integer deleteByParams(@Param("params") Map<String,Object> params);

    /**
     * 获取数量
     * @param params
     * @return
     */
    public abstract Integer selectCount(@Param("params") Map<String,Object> params);

    /**
     * 获取分页列表
     * @param page
     * @param params
     * @param orderByField
     * @param orderBy
     * @param <ModelType>
     * @return
     */
    public abstract <ModelType> List<ModelType> selectByPage(@Param("page") SinglePage page, @Param("params") Map<String,Object> params,
                                                             @Param("orderByField") String orderByField, @Param("orderBy") String orderBy);

    /**
     * 根据参数获取列表
     * @param params
     * @return
     */
    public abstract <ModelType> List<ModelType> selectByParam(@Param("params") Map<String, Object> params);

    /**
     * 通过handler 获取数据
     * @param params
     * @param handler
     * @param <ModelType>
     */
    public abstract  <ModelType> void getDataByHandler(@Param("params") Map<String, Object> params, ResultHandler<ModelType> handler);

    public abstract void getMapDataByHandler(@Param("params") Map<String, Object> params, ResultHandler<Map<String, Object>> handler);


    /**
     * 通过handler 获取数据
     * @param params
     * @param handler
     * @param <ModelType>
     */
    public abstract  <ModelType> void getPageDataByHandler(@Param("params") Map<String, Object> params, ResultHandler<ModelType> handler);

    /**
     * 根据model获取单条
     * @param modelType
     * @return
     */
    public abstract <ModelType> ModelType selectSingleByModel(@Param("params") ModelType modelType);
}
